|
In software engineering, double-checked locking (also known as "double-checked locking optimization"〔Schmidt, D et al. Pattern-Oriented Software Architecture Vol 2, 2000 pp353-363〕) is a software design pattern used to reduce the overhead of acquiring a lock by first testing the locking criterion (the "lock hint") without actually acquiring the lock. Only if the locking criterion check indicates that locking is required does the actual locking logic proceed. The pattern, when implemented in some language/hardware combinations, can be unsafe. At times, it can be considered an anti-pattern.〔David Bacon et al. (The "Double-Checked Locking is Broken" Declaration ).〕 It is typically used to reduce locking overhead when implementing "lazy initialization" in a multi-threaded environment, especially as part of the Singleton pattern. Lazy initialization avoids initializing a value until the first time it is accessed. == Usage in C++11 == For the singleton pattern, double-checked locking is not needed: Use C++11 acquire and release fences as given by 〔 (Double-Checked Locking is Fixed In C++11 )〕 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Double-checked locking」の詳細全文を読む スポンサード リンク
|